<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/common.css" media="all">
    <link rel="stylesheet" href="../viewstyle/css/publicform.css">
    <script src="/js/layui/layui.js"></script>
    <!--<script src="/admin/js/token.js"></script>-->
    <script src="../viewstyle/config/config2.js"></script>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="station" class="layui-hide" lay-filter="t"></table>
        </div>
    </div>
</div>
</body>

<script type="text/html" id="tb">
    <div class="layui-container">
        <button class="layui-btn layui-btn-sm layui-icon layui-icon-add-1" lay-event="addstation">
            新增站点
        </button>
    </div>
</script>

<script type="text/html" id="delAndEdit">
    <input type="button" id="editpassword" value="修改密码" class="layui-btn layui-btn-xs" lay-event="editpassword"/>
    <input type="button" value="编辑" class="layui-btn layui-btn-xs" lay-event="editstation"/>
    <input type="button" value="站点配置" class="layui-btn layui-btn-xs" lay-event="peizhi"/>
</script>

<script>
    layui.use([ 'form', 'table'], function () {
        var $ = layui.$;
        var form = layui.form;
        var table = layui.table;
        var adminid=layui.data("treeadminid").adminid
        table.render({
            elem: '#station',
            url: '/admin/station/selectAllStation?adminid='+adminid,
            id: 't',
            toolbar: '#tb',
            cols: [[{
                title: '站点编号',
                field: 'station_bh',
                width: '10%',
                fixed: 'left',
                align: 'center'
            }
                , {
                    title: '站点名称',
                    field: 'station_name',
                    width:"15%",
                    align: 'center'
                }
                , {
                    title: '区域',
                    field: 'station_quyu',
                    width: '10%',
                    align: 'center'
                }
                , {
                    title: '类型',
                    field: 'station_type_name',
                    width: '10%',
                    align: 'center'
                }
                , {
                    title: '模式',
                    field: 'station_model',
                    width: '6%',
                    align: 'center',
                    hide:true
                }
                , {
                    title: '最大终端数',
                    field: 'station_maximum_number_of_terminals',
                    width: '9%',
                    align: 'center',
                    hide:true
                }
                , {
                    title: '已绑定终端数',
                    field: 'staion_current_number_o_terminals',
                    width: '10%',
                    align: 'center',
                    hide:true
                }
                , {
                    title: '联系电话',
                    field: 'station_phone',
                    width:"15%",
                    align: 'center'
                }
                , {
                    title: '密码',
                    field: 'station_password',
                    width: '20%',
                    align: 'center'
                }
                , {
                    title: '创建时间',
                    field: 'station_create_time',
                    align: 'center',
                    hide:true
                }
                , {
                    title: '上级用户',
                    field: 'admin_name',
                    align: 'center',
                    hide:true
                }
                , {
                    title: 'id',
                    field: 'station_id',
                    hide: true
                }
                , {
                    title: '直播服务器ip',
                    field: 'station_local_server_ip',
                    hide: true
                }
                , {
                    title: '点播服务器IP',
                    field: 'vod_server_ip',
                    hide: true
                }
                , {
                    title: 'vpn',
                    field: 'station_vpn',
                    hide: true
                }
                , {
                    title: '提示',
                    field: 'station_locktip',
                    hide: true
                }
                , {
                    title: 'dzb',
                    field: 'station_dzb_ip',
                    hide: true
                }
                , {
                    title: 'station_province',
                    field: 'station_province',
                    hide: true
                }
                , {
                    title: 'station_oss',
                    field: 'station_oss',
                    hide: true
                }
                , {
                    title: 'modol',
                    field: 'station_model',
                    hide: true
                }
                , {
                    title: 'address_id',
                    field: 'address_id',
                    hide: true
                }
                , {
                    title: 'station_area',
                    field: 'station_area',
                    hide: true
                }
                , {
                    title: 'station_admin_id',
                    field: 'station_admin_id',
                    hide: true
                }
                , {
                    title: '操作',
                    width: '20%',
                    align: 'center',
                    toolbar: '#delAndEdit',
                    fixed: 'right'
                }
            ]],
            page: true,
            limit:40
        })

        //添加和返回的监听事件
        table.on('toolbar(t)', function (obj) {
            var e = obj.event;
            switch (e) {
                case 'addstation':
                    layer.open({
                        title: "新增站点",
                        content: "AddStation.html",
                        type: 2,
                        area: ["100%", "100%"]
                    })
                    break;
            }
        })

        //    右侧按钮的的监听事件
        table.on('tool(t)', function (obj) {
            var getdata = obj.data //获得当前行数据
            var layEvent = obj.event //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr //获得当前行 tr 的 DOM 对象（如果有的话）
            switch (layEvent) {
                case 'editpassword':
                    layui.data('stationdata', {
                        key: 'getdata',
                        value: getdata
                    })
                    layer.open(
                        {
                            title: '修改密码',
                            content: 'EditStationPassword.html',
                            type: 2,
                            area: ['100%', '100%'],
                            end: function () {
                                $(".layui-laypage-btn").click();
                            }
                        }
                    )
                    break
                case 'editstation':
                    layui.data('updatedata', {
                        key: 'getdata',
                        value: getdata
                    })
                    layer.open(
                        {
                            title: '编辑',
                            content: 'EditStation.html',
                            type: 2,
                            area: ['100%', '100%'],
                            end: function () {
                                $(".layui-laypage-btn").click();
                            }
                        }
                    )
                    break;
                case "peizhi":
                    open('/admin/station_config/index.html?id='+getdata.station_id+'#/layui/grid');
                    break;

            }
        })
    })
</script>
</html>
